*************************************************************************
************ Table 1: Summary Statistics for Communities ****************
*************************************************************************

cd $PATH

use urban_index.dta, clear

merge 1:1 commid WAVE using so2_match_long.dta, keep(match) nogen 

global xlist comm denc div econ health house market soc trans edc mart sani so2_total_ann so2_power_ann so2_manu_ann

eststo all: quietly estpost summarize $xlist
eststo ntcz: quietly estpost summarize $xlist if tcz==0
eststo tcz: quietly estpost summarize $xlist if tcz==1
eststo diff: quietly estpost ttest $xlist, by(tcz)

* Tables produced by estout (Jann 2005, 2007)
* Jann, Ben (2005): Making regression tables from stored estimates. The Stata Journal 5(3): 288-308.
* Jann, Ben (2007): Making regression tables simplified. The Stata Journal 7(2): 227-244.

esttab all ntcz tcz diff using tab1_summary.tex, star(* 0.10 ** 0.05 *** 0.01) ///
cells("mean(pattern(1 1 1 0) fmt(2)) sd(pattern(1 0 0 0) fmt(2)) b(star pattern(0 0 0 1) fmt(2))") nonum noobs nolabel  ///
mtitles("Overall Mean" "SD" "Mean (non-TCZ)" "Mean (TCZ)" "Mean Difference") prehead("\begin{tabular}{l*{5}{c}} \hline\hline") nolines replace fragment 

